package com.logic.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration  //项目启动时加载此类
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket all(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("项目模块所有接口")
                .select()
                // 此处自行修改为自己的 Controller 包路径。
                .apis(RequestHandlerSelectors.basePackage("com"))
                .paths(PathSelectors.any())
                .build();
    }    

    @Bean
    public Docket cultivate(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("养成")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.game.modular.act.cultivate"))
                .paths(PathSelectors.any())
                .build();
    }
    @Bean
    public Docket test(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("测试")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.logic.modular.act.test"))
                .paths(PathSelectors.any())
                .build();
    }//

    @Bean
    public Docket CombatRelated(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("对局")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.game.modular.act.battle"))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public Docket info(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("玩家相关")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.game.modular.act.playerInfo"))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public Docket base(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("基础信息")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.game.modular.gameCore"))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public Docket gameGm(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("游戏gm")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.game.modular.gameGm"))
                .paths(PathSelectors.any())
                .build();
    }
    
    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("游戏接口")
                .description("游戏接口")  //说明信息
                .version("1.0")  //文档版本
                .build();
    }
}
